package com.bjkcst.baselib.utils;

import android.content.Context;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;


/**
 * 全局Toast
 *
 * @author admin
 */
public class ToastUtil {

    /**
     *
     * @param context 上下文
     * @param msg toast文本
     */
    public static void showToast(Context context, String msg) {
        try {
            Toast toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
            LinearLayout layout = (LinearLayout) toast.getView();
            TextView tv = (TextView) layout.getChildAt(0);
            tv.setTextSize(24);
            toast.setGravity(Gravity.BOTTOM, 0, 0);
            toast.setText(msg);
            toast.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
